//
//  FMEggBehaviorView.m
//  物理仿真
//
//  Created by Annie on 2020/5/23.
//  Copyright © 2020 Annie. All rights reserved.
//

#import "FMEggBehaviorView.h"
#import "FRButton.h"

@interface FMEggBehaviorView ()
@property (nonatomic, strong) UIButton *btn;
@end


@implementation FMEggBehaviorView

- (void)setFr_status:(NSInteger)fr_status{
    _fr_status = fr_status;
    
    NSString *normal = @"cat";
    NSString *catched = @"dog";
    NSString *notCatched = @"baonu";
    
    normal = @"smile";
    catched = @"happy";
//    notCatched = @"cry";
    
    if (fr_status == kFREggStatusNormal) {
         [self.btn setBackgroundImage:[UIImage imageNamed:normal] forState:UIControlStateNormal];
    }else if (fr_status == kFREggStatusCatched){
         [self.btn setBackgroundImage:[UIImage imageNamed:catched] forState:UIControlStateNormal];
    }else if (fr_status == kFREggStatusNotCatched){
        //
        [self.btn setBackgroundImage:[UIImage imageNamed:notCatched] forState:UIControlStateNormal];
    }
    
}


- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self fm_configSubViews];
    }
    return self;
}
- (void)fm_configSubViews{
    
    [self addSubview:self.btn];
    self.fr_status = kFREggStatusNormal;

}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.btn.frame = self.bounds;
}

- (UIButton *)btn{
    if (!_btn) {
        UIButton *btn = [FRButton new];
        [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside];
        _btn = btn;
    }
    return _btn;
}


- (void)btnDidClicked:(UIButton *)sender{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(catchedWithEggBehaviorView:)]) {
        [self.delegate catchedWithEggBehaviorView:self];
    }
    
}


@end
